package com.activitycode.adapter;

import java.util.List;

import com.activitycode.datamodel.model.PetInfo;
import com.activitycode.fragment.PetMeAdapter.ViewHolder;
import com.activitycode.util.CommConstant;
import com.duostec.zhuyue.pets.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class ChooseMyPetAdapter extends BaseAdapter {

	public Context context;
	private List<PetInfo> infoList;
	public ChooseMyPetAdapter adapter;

	public ChooseMyPetAdapter(Context context, List<PetInfo> infoList) {
		// TODO Auto-generated constructor stub
		this.context = context;
		this.infoList = infoList;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return infoList.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return infoList.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ViewHolder viewHolder = null;

		if (convertView == null) {
			viewHolder = new ViewHolder();
			convertView = LayoutInflater.from(context).inflate(
					R.layout.ui_choose_mypet, null);

			viewHolder.type = (TextView) convertView
					.findViewById(R.id.pettype);
			viewHolder.name = (TextView) convertView
					.findViewById(R.id.petname);

			convertView.setTag(viewHolder);
		} else {

			viewHolder = (ViewHolder) convertView.getTag();
		}

		viewHolder.name.setText(infoList.get(position).getPetName());

		viewHolder.type.setText(infoList.get(position).getName());

		return convertView;
	}

	public final static class ViewHolder {
		TextView type, name;

	}

}
